home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / quicktime / quicktime for java / zoo tutorial / module 9- full screen mode / completed source / zoo9.java < prev    next >
Encoding:
Java Source  |  2000-09-28  |  4.5 KB  |  133 lines

  1. import java.awt.Color;
  2. import java.awt.GridBagLayout;
  3. import java.awt.GridBagConstraints;
  4.  
  5. import quicktime.QTSession;
  6. import quicktime.QTException;
  7.  
  8. import com.apple.mrj.MRJApplicationUtils;
  9. import com.apple.mrj.MRJQuitHandler;
  10.  
  11. import quicktime.app.display.FullScreenWindow;
  12. import quicktime.std.movies.FullScreen;
  13.  
  14. /**
  15.  * QTZoo Module 9 - Using Full Screen Mode
  16.  * This application requires QuickTime for Java
  17.  *
  18.  * @author Levi Brown
  19.  * @author Michael Hopkins
  20.  * @author Apple Computer, Inc.
  21.  * @version 9.0 4/10/2000
  22.  * 
  23.  * Copyright:     © Copyright 1999 Apple Computer, Inc. All rights reserved.
  24.  *    
  25.  * Disclaimer:    IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
  26.  *                ("Apple") in consideration of your agreement to the following terms, and your
  27.  *                use, installation, modification or redistribution of this Apple software
  28.  *                constitutes acceptance of these terms.  If you do not agree with these terms,
  29.  *                please do not use, install, modify or redistribute this Apple software.
  30.  *
  31.  *                In consideration of your agreement to abide by the following terms, and subject
  32.  *                to these terms, Apple grants you a personal, non-exclusive license, under Apple’s
  33.  *                copyrights in this original Apple software (the "Apple Software"), to use,
  34.  *                reproduce, modify and redistribute the Apple Software, with or without
  35.  *                modifications, in source and/or binary forms; provided that if you redistribute
  36.  *                the Apple Software in its entirety and without modifications, you must retain
  37.  *                this notice and the following text and disclaimers in all such redistributions of
  38.  *                the Apple Software.  Neither the name, trademarks, service marks or logos of
  39.  *                Apple Computer, Inc. may be used to endorse or promote products derived from the
  40.  *                Apple Software without specific prior written permission from Apple.  Except as
  41.  *                expressly stated in this notice, no other rights or licenses, express or implied,
  42.  *                are granted by Apple herein, including but not limited to any patent rights that
  43.  *                may be infringed by your derivative works or by other works in which the Apple
  44.  *                Software may be incorporated.
  45.  *
  46.  *                The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
  47.  *                WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
  48.  *                WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  49.  *                PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
  50.  *                COMBINATION WITH YOUR PRODUCTS.
  51.  *
  52.  *                IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
  53.  *                CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  54.  *                GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  55.  *                ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
  56.  *                OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
  57.  *                (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
  58.  *                ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  59.  * 
  60.  */
  61.  
  62. public class Zoo9 implements MRJQuitHandler
  63. {
  64.     /**
  65.      *  Zoo constructor
  66.      */
  67.     public Zoo9() 
  68.     {
  69.         MRJApplicationUtils.registerQuitHandler(this);            // register handler for command-Q
  70.         try
  71.         {    
  72.             window = new FullScreenWindow(new FullScreen());    // create a new fullscreen window
  73.             window.setBackground (Color.black);                    // color window black
  74.             window.setLayout(new GridBagLayout());
  75.             gbc = new GridBagConstraints();
  76.             gbc.gridx = 1;
  77.             gbc.gridy = 1;
  78.             gbc.gridwidth = 1;
  79.             gbc.anchor = GridBagConstraints.CENTER;
  80.             gbc.fill = GridBagConstraints.NONE;
  81.  
  82.             window.show();
  83.             run();
  84.         }
  85.         catch (QTException exc)
  86.         {
  87.             exc.printStackTrace();
  88.         }
  89.     }
  90.     
  91.     /**
  92.      * Main body of class. Creates main window, and displays it
  93.      */
  94.     public void run()
  95.     {
  96.         mainFrame = new MainFrame(window);
  97.         mainFrame.setVisible(true);
  98.         ((GridBagLayout)window.getLayout()).setConstraints(mainFrame, gbc);
  99.         window.add(mainFrame);
  100.         mainFrame.invalidate();
  101.         window.validate();
  102.     }
  103.     
  104.     /**
  105.      * Handles quitting the application.
  106.      * This routine gets called by the MRJToolkit when the
  107.      * application is about to quit.
  108.      */
  109.     public void handleQuit()
  110.     {
  111.         mainFrame.handleQuit();
  112.     }
  113.  
  114.     static public void main(String[] args) 
  115.     {
  116.         try
  117.         {
  118.             QTSession.open();            // Initialize QuickTime 
  119.             new Zoo9();    
  120.         }
  121.         catch (Exception e) 
  122.         {
  123.             e.printStackTrace();
  124.             QTSession.close();            // Shut down QuickTime and dispose of native context
  125.         }
  126.     }
  127.     
  128.     protected MainFrame mainFrame;
  129.     
  130.     protected FullScreenWindow window;
  131.     protected GridBagConstraints gbc;
  132. }
  133.